<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>张家口客车租赁后台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<style type="text/css">
    .barcon {
        width: 1000px;
        margin: 0 auto;
        text-align: center;
    }
    .barcon1 {
        font-size: 17px;
        float: left;
        margin-top: 20px;
    }
    .barcon2 {
        float: right;
    }
    .barcon2 ul {
        margin: 20px 0;
        padding-left: 0;
        list-style: none;
        text-align: center;
    }
    .barcon2 li {
        display: inline;
    }
    .barcon2 a {
        font-size: 16px;
        font-weight: normal;
        display: inline-block;
        padding: 5px;
        padding-top: 0;
        color: black;
        border: 1px solid #ddd;
        background-color: #fff;
    }
    .barcon2 a:hover{
        background-color: #eee;
    }
    .ban {
        opacity: .4;
    }
</style>


<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
              <cite>导航元素</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <!--<div class="layui-card-body ">-->
                    <!--<form class="layui-form layui-col-space5">-->
                        <!--<div class="layui-inline layui-show-xs-block">-->
                            <!--<input class="layui-input"  autocomplete="off" placeholder="开始日" name="start" id="start">-->
                        <!--</div>-->
                        <!--<div class="layui-inline layui-show-xs-block">-->
                            <!--<input class="layui-input"  autocomplete="off" placeholder="截止日" name="end" id="end">-->
                        <!--</div>-->
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="comment_user_id"  id="comment_user_id" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn"  onclick="commentusernamenlist()"><i class="layui-icon">&#xe615;</i></button>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="comment_driver_id" id="comment_driver_id"  placeholder="请输入司机账号" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn"  onclick="commentdrivernamenlist()"><i class="layui-icon">&#xe615;</i></button>
                        </div>
                    <!--</form>-->
                <!--</div>-->
                <!--<div class="layui-card-header">-->
                    <!--&lt;!&ndash;<button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>&ndash;&gt;-->
                    <!--<button class="layui-btn" onclick="xadmin.open('添加用户','./commentadd.html',600,400)"><i class="layui-icon"></i>添加</button>-->
                <!--</div>-->
                <div class="layui-card-body ">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>
                                <input type="checkbox" name=""  lay-skin="primary">
                            </th>
                            <th>编号</th>
                            <th>任务编号</th>
                            <th>分数</th>
                            <th>照片</th>
                            <th>用户编号</th>
                            <th>查看司机</th>
                            <th>备注</th>
                            <th>说明</th>
                            <th>操作</th>
                        </thead>
                        <tbody class="student-list" id="adminTbody">


                        </tbody>
                    </table>
                </div>

                <div id="barcon" class="barcon" >
                    <div id="barcon1" class="barcon1"></div>
                    <div id="barcon2" class="barcon2">
                        <ul>
                            <li><a href="###" id="firstPage">首页</a></li>
                            <li><a href="###" id="prePage">上一页</a></li>
                            <li><a href="###" id="nextPage">下一页</a></li>
                            <li><a href="###" id="lastPage">尾页</a></li>
                            <li>
                            <select id="jumpWhere">
                            </select>
                            </li>
                            <li><a href="###" id="jumpPage">跳转</a></li>
                        </ul>
                    </div>
                </div>


            </div>
        </div>
    </div>
</div>
</body>
<script src="js/jquery.min.js"></script>
<script>
    $(function(){
        $.ajax({
            type:"POST",
            url:"/commentListall",
            datatype:'json',
            success:function(data){
                if(data.status==401){
                    alert("熔断开启，系统异常");
                    window.location.href="login.html";
                    return;
                }
                var  lists = data.data;
                console.log(data);
                for (var i = 0; i < lists.length; i++){
                    var html = "";
                    html +=`
                        <tr>
                            <td>
                                <input type="checkbox" name=""  lay-skin="primary">
                            </td>
                            <td>${lists[i].comment_id}</td>
                            <td>${lists[i].comment_task_id}</td>
                            <td>${lists[i].comment_fraction}</td>
                            <td width="5%"><img src="/imgshows?picName=${lists[i].comment_photo}"/></td>
                            <td>
                               <a title="查看用户"  onclick="memberuserid(this,${lists[i].comment_user_id})"  href="javascript:;">
                                    <i  class="layui-icon">&#xe642;</i>
                                </a>
                            </td>
                            <td>
                                <a title="查看司机信息"  onclick="memberdriverid(this,${lists[i].comment_driver_id})" href="javascript:;">
                                        <i class="layui-icon">&#xe642;</i>
                                </a>
                            </td>
                            <td>${lists[i].comment_remarks}</td>
                            <td>${lists[i].comment_s}</td>
                            <td class="td-manage">
                                <a title="删除" onclick="memberdel(this,${lists[i].comment_id})" href="javascript:;">
                                    <i class="layui-icon">&#xe640;</i>
                                </a>
                            </td>
                        </tr>
                    `
                    $('.student-list').append(html);
                }
                //分页
                goPage(1,8);
                var tempOption="";
                for(var i=1;i<= totalPage ;i++)
                {
                    tempOption+='<option value='+i+'>'+i+'</option>'
                }
                $("#jumpWhere").html(tempOption);
            }
        })

    })
    var pageSize=8;//每页显示行数
    var currentPage_=1;//当前页全局变量，用于跳转时判断是否在相同页，在就不跳，否则跳转。
    var totalPage;//总页数
    function goPage(pno,psize){
        var itable = document.getElementById("adminTbody");
        var num = itable.rows.length;//表格所有行数(所有记录数)
        pageSize = psize;//每页显示行数
        //总共分几页
        if(num/pageSize > parseInt(num/pageSize)){
            totalPage=parseInt(num/pageSize)+1;
        }else{
            totalPage=parseInt(num/pageSize);
        }
        var currentPage = pno;//当前页数
        currentPage_=currentPage;
        var startRow = (currentPage - 1) * pageSize+1;
        var endRow = currentPage * pageSize;
        endRow = (endRow > num)? num : endRow;
        //遍历显示数据实现分页
        // for(var i=1;i<(num+1);i++){
        //     var irow = itable.rows[i-1];
        //     if(i>=startRow && i<=endRow){
        //         irow.style.display = "";
        //     }else{
        //         irow.style.display = "none";
        //     }
        // }


        $("#adminTbody tr").hide();
        for(var i=startRow-1;i<endRow;i++)
        {
            $("#adminTbody tr").eq(i).show();
        }
        var tempStr = "共"+num+"条记录 分"+totalPage+"页 当前第"+currentPage+"页";
        document.getElementById("barcon1").innerHTML = tempStr;
        if(currentPage>1){
            $("#firstPage").on("click",function(){
                goPage(1,psize);
            }).removeClass("ban");
            $("#prePage").on("click",function(){
                goPage(currentPage-1,psize);
            }).removeClass("ban");
        }else{
            $("#firstPage").off("click").addClass("ban");
            $("#prePage").off("click").addClass("ban");
        }
        if(currentPage<totalPage){
            $("#nextPage").on("click",function(){
                goPage(currentPage+1,psize);
            }).removeClass("ban")
            $("#lastPage").on("click",function(){
                goPage(totalPage,psize);
            }).removeClass("ban")
        }else{
            $("#nextPage").off("click").addClass("ban");
            $("#lastPage").off("click").addClass("ban");
        }
        $("#jumpWhere").val(currentPage);
        $("#jumpPage").on("click",function(){
            var num=parseInt($("#jumpWhere").val());
            if(num!=currentPage_)
            {
                goPage(num,psize);
            }
        }).removeClass("ban")
    }

</script>
<script>
    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var form = layui.form;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });


    function memberuserid (obj,id) {
        console.log(id);
        if(id == null) {
            alert("该数据异常，建议删除");
            return;

        }else{
            localStorage.setItem("task_user_id", id);
            xadmin.open('查看用户信息', './useridlist.html', 800, 600);
            return;
        }
    }

    function memberup(obj,id){
        console.log(id);
        localStorage.setItem("comment_id",id);
        window.location.href="commentup.html";
    }

    function commentdrivernamenlist () {
        var comment_driver_id = $("#comment_driver_id").val();
        $.ajax({
            type: "post",
            url: "/commentdrivernamenlist",
            data: ({
                driver_name_n: comment_driver_id
            }),
            success: function (data) {
                console.log(data);
                if(data.status == 20) {
                    alert("请核查您输入的账号");
                    window.location.href = "commentlist.html";
                    return;
                }
                if(data.status == 500) {
                    alert("核实清楚");
                    window.location.href = "commentlist.html";
                    return;
                }
                if (data.status == 200) {
                    $('.student-list').html("");
                    var lists = data.data;
                    console.log(data);
                    for (var i = 0; i < lists.length; i++) {
                        var html = "";
                        html += `
                         <tr>
                            <td>
                                <input type="checkbox" name=""  lay-skin="primary">
                            </td>
                            <td>${lists[i].comment_id}</td>
                            <td>${lists[i].comment_task_id}</td>
                            <td>${lists[i].comment_fraction}</td>
                            <td width="5%"><img src="/imgshows?picName=${lists[i].comment_photo}"/></td>
                            <td>
                               <a title="查看用户"  onclick="memberuserid(this,${lists[i].comment_user_id})"  href="javascript:;">
                                    <i  class="layui-icon">&#xe642;</i>
                                </a>
                            </td>
                            <td>
                                <a title="查看司机信息"  onclick="memberdriverid(this,${lists[i].comment_driver_id})" href="javascript:;">
                                        <i class="layui-icon">&#xe642;</i>
                                </a>
                            </td>
                            <td>${lists[i].comment_remarks}</td>
                            <td>${lists[i].comment_s}</td>
                            <td class="td-manage">
                                <a title="删除" onclick="memberdel(this,${lists[i].comment_id})" href="javascript:;">
                                    <i class="layui-icon">&#xe640;</i>
                                </a>
                            </td>
                        </tr>
                                `
                        $('.student-list').append(html);
                    }
                    goPage(1,8);
                    var tempOption="";
                    for(var i=1;i<= totalPage ;i++)
                    {
                        tempOption+='<option value='+i+'>'+i+'</option>'
                    }
                    $("#jumpWhere").html(tempOption);
                    if (data.status == 500) {
                        alert("添加错误");
                        window.location.href = "userlist.html";
                        return;
                    }
                }
            }
        })
    }



    function commentusernamenlist () {
        var comment_user_id = $("#comment_user_id").val();
        $.ajax({
            type: "post",
            url: "/commentusernamenlist",
            data: ({
                user_name_n: comment_user_id
            }),
            success: function (data) {
                console.log(data);
                if(data.status == 20) {
                    alert("请核查您输入的账号");
                    window.location.href = "commentlist.html";
                    return;
                }
                if(data.status == 500) {
                    alert("核实清楚");
                    window.location.href = "commentlist.html";
                    return;
                }
                if (data.status == 200) {
                    $('.student-list').html("");
                    var lists = data.data;
                    console.log(data);
                    for (var i = 0; i < lists.length; i++) {
                        var html = "";
                        html += `
                         <tr>
                            <td>
                                <input type="checkbox" name=""  lay-skin="primary">
                            </td>
                            <td>${lists[i].comment_id}</td>
                            <td>${lists[i].comment_task_id}</td>
                            <td>${lists[i].comment_fraction}</td>
                            <td width="5%"><img src="/imgshows?picName=${lists[i].comment_photo}"/></td>
                            <td>
                               <a title="查看用户"  onclick="memberuserid(this,${lists[i].comment_user_id})"  href="javascript:;">
                                    <i  class="layui-icon">&#xe642;</i>
                                </a>
                            </td>
                            <td>
                                <a title="查看司机信息"  onclick="memberdriverid(this,${lists[i].comment_driver_id})" href="javascript:;">
                                        <i class="layui-icon">&#xe642;</i>
                                </a>
                            </td>
                            <td>${lists[i].comment_remarks}</td>
                            <td>${lists[i].comment_s}</td>
                            <td class="td-manage">
                                <a title="删除" onclick="memberdel(this,${lists[i].comment_id})" href="javascript:;">
                                    <i class="layui-icon">&#xe640;</i>
                                </a>
                            </td>
                        </tr>
                                `
                        $('.student-list').append(html);
                    }
                    goPage(1,8);
                    var tempOption="";
                    for(var i=1;i<= totalPage ;i++)
                    {
                        tempOption+='<option value='+i+'>'+i+'</option>'
                    }
                    $("#jumpWhere").html(tempOption);
                    if (data.status == 500) {
                        alert("添加错误");
                        window.location.href = "userlist.html";
                        return;
                    }
                }
            }
        })
    }


    /*用户-删除*/
    function memberdel(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            console.log(id);
            $.ajax({
                type:"POST",
                url: "/deletecomment",
                data:({
                    driver_id:id
                }),
                success: function (data) {
                    console.log(data);
                    if(data.status==401){
                        alert("熔断开启，系统异常");
                        window.location.href="./login.html";
                        return;
                    }
                    if(data.status==200){
                        window.location.reload();
                        $(".layui-form-checked").not('.header').parents('tr').remove();
                    }
                    if(data.status==500){
                        alert("删除S");
                        window.location.reload();
                        $(".layui-form-checked").not('.header').parents('tr').remove();
                    }
                }
            })
            $(obj).parents("tr").remove();
            layer.msg('已删除!',{icon:1,time:1000});
        });
    }



    function delAll (argument) {

        var data = tableCheck.getData();

        layer.confirm('确认要删除吗？'+data,function(index){
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
            $(".layui-form-checked").not('.header').parents('tr').remove();
        });
    }


    function memberdriverid(obj,id) {
        if (id==null){
            alert("建议删除这一条信息")
            return;
        }
        localStorage.setItem("bus_driver_id",id);
        xadmin.open('查看司机信息','./driveridlist.html',800,600)
        return;
    }
</script>

</html>